﻿@using System.Linq.Expressions;
@using Microsoft.AspNetCore.Authorization;
@using Microsoft.Extensions.Logging
@using ThingsGateway.Admin.Application;
@using ThingsGateway.Admin.Razor
@using ThingsGateway.Core.Extension
@using ThingsGateway.Gateway.Application
@using BootstrapBlazor.Components
@namespace ThingsGateway.Plugin.TDengineDB


<AdminTable TItem="TDengineDBHistoryValue" AutoGenerateColumns="false" ShowDefaultButtons=false
                AllowResizing="true" IsFixedHeader=true IsMultipleSelect=false
                ShowExtendEditButton=false ShowExtendDeleteButton=false ShowExtendButtons=false
            ShowExportButton="true" IsAutoQueryFirstRender=false
                OnQueryAsync="OnQueryAsync" IsPagination=true CustomerSearchModel="@CustomerSearchModel">
        <CustomerSearchTemplate>
        @if (context is TDengineDBPageInput model)
            {
                @Render(model)
            }
        </CustomerSearchTemplate>
    <TableColumns>
        <TableColumn @bind-Field="@context.DeviceName" ShowTips=true Filterable=true Sortable=true Visible=true />
        <TableColumn @bind-Field="@context.Name" ShowTips=true Filterable=true Sortable=true Visible=true />
        <TableColumn @bind-Field="@context.Value" ShowTips=true Filterable=true Sortable=true Visible=true />
        <TableColumn Field="@context.CollectTime" ShowTips=true FieldExpression=@(()=>context.CollectTime) Filterable=true Sortable=true Visible=true />
        <TableColumn Field="@context.IsOnline" FieldExpression=@(()=>context.IsOnline) Filterable=true Sortable=true Visible=true />
        <TableColumn @bind-Field="@context.Id" Visible="false" DefaultSort=true DefaultSortOrder="SortOrder.Asc" />

    </TableColumns>
    </AdminTable>

@code {
    RenderFragment Render(TDengineDBPageInput model) =>
    @<div class="row form-inline g-2">
        <div class="col-12 ">
            <BootstrapInput @bind-Value="model.VariableName" ShowLabel="true" />
        </div>
        <div class="col-12 ">
            <DateTimeRange @bind-Value="model.SearchDate" ShowLabel="true" />
        </div>
    </div>;

}
